<?php

//纯PHP页面的中文乱码问题（数据是静态的）
header("Content-Type: text/html; charset: utf-8");

//PHP+Mysql中文乱码问题
mysql_query('SET NAMES UTF8');

//解析config.ini文件
$config = parse_ini_file(realpath(dirname(__FILE__) . '/config/config.ini'));

//从config 中获取数据库相关属性
$servername = $config["dbServername"];
$username = $config["dbUsername"];
$password = $config["dbPassword"];
$dbName = $config["dbName"];

//数据库连接

$mysqli = new mysqli("localhost", "root", "gcy888999", "myboot");
mysqli_set_charset($mysqli, 'utf8');

//检测连接
if(mysqli_connect_error()) {
    die("连接失败: " . $conn->connect_error);
}

//条件选取

$result = mysqli_query($mysqli, "SELECT * FROM t_user ORDER BY password");
while($row = mysqli_fetch_array($result)) {
    echo $row["username"] . " " . $row["password"];
    echo "<br>";
}

//更新数据
// $resultBoolen = mysqli_query($mysqli, "UPDATE user SET password='15306325240' where username ='orange'");
// if($resultBoolen) {
//     echo "更新数据成功";
// }
//删除数据
mysqli_query($mysqli, "DELETE FROM user WHERE username='gaol'");

mysqli_close($mysqli);